package com.twogroup;

class Animals{
    protected int zhongchengdu=0;
    protected String type="";
    public int getZhongchengdu() {
        return zhongchengdu;
    }
    public String getType() {
        return type;
    }
    //训练
    public void walk(){
        System.out.println("父类Animal的walk");
    }

}
class Cat extends Animals{
    @Override
    public void walk(){
        this.zhongchengdu++;
        System.out.println("小猫的忠诚度+1");
    }

}
class Dog extends Animals{

    //默认
    public Dog(){
        this.zhongchengdu+=5;
        System.out.println("默认遛狗方式，忠诚度加5");
    }
    public  Dog(String type,int zhong){
        this.type=type;
        this.zhongchengdu=zhong;
    }
    public void walk(){
        this.zhongchengdu++;
    }
    public  void  walk(String style){
        this.zhongchengdu+=5;
    }

}

public class test {

    public static void main(String[] args) {
        Dog dog1=new Dog();
        System.out.println(dog1.getType()+"="+dog1.getZhongchengdu());
        dog1.walk();
        System.out.println(dog1.getType()+"="+dog1.getZhongchengdu());
        Dog dog2=new Dog("二哈",100);
        System.out.println(dog2.getType()+"="+dog2.getZhongchengdu());
        dog2.walk("二哈");
        System.out.println(dog2.getType()+"="+dog2.getZhongchengdu());
        Animals cat1=new Cat();
        System.out.println(cat1.getType()+"="+cat1.getZhongchengdu());
        cat1.walk();
        System.out.println(cat1.getType()+"="+cat1.getZhongchengdu());
    }
}
